#pragma once

#include <iostream>
#include "./req_files/add_req.pb.h"
#include "./res_files/add_res.pb.h"
#include "./req_files/find_one_req.pb.h"
#include "./res_files/find_one_res.pb.h"
#include "./res_files/find_all_res.pb.h"
#include "./req_files/del_req.pb.h"
#include "./res_files/del_res.pb.h"
#include"./bin_file_oper/contacts.pb.h"
#include"./utils/util.hpp"

class ContactsServer
{

public:
    // 服务端拿到请求进行解析到自己的请求proto对象中；然后进行处理之后构成response的proto对象最后发送出去：
    void Add(add_contact_req::AddContactRequest &req, add_contact_res::AddContactResponse *res);
    void Del(del_req::DelContactRequest &req, del_res::DelContactResponse *res);
    void FindOne(find_one_req::FindOneContactRequest &req, find_one_res::FindOneContactResponse *res);
    void FindAll(find_all_contacts_resp::FindAllContactsResponse *res);

private:
    void PrintWillAddContactPeople(add_contact_req::AddContactRequest req);                     // 打印出日志：要添加的联系人信息
    void BuildPeopleInfo(add_contact_req::AddContactRequest req, contacts::PeopleInfo *people); // 联系人信息proto格式转化
    void BuildFindOneContactResponse(find_one_res::FindOneContactResponse *res, contacts::PeopleInfo people);//建造一个Findone的答复
    void BuildFindAllResponse(contacts::Contacts & contacts,find_all_contacts_resp::FindAllContactsResponse *res);//把对应的遍历的联系人信息都保存到res中
};